package com.eksisozluk.eksidroid.remote.service;

import com.eksisozluk.eksidroid.common.page.IndexPage;
import com.eksisozluk.eksidroid.common.page.Page;
import com.eksisozluk.eksidroid.remote.fetcher.ContentFetcher;
import com.eksisozluk.eksidroid.remote.parser.PageParser;
import com.google.inject.Inject;

public class DefaultRemoteService implements IRemoteService
{
	private ContentFetcher	contentFetcher;
	private PageParser		pageParser;

	@Inject
	public DefaultRemoteService(ContentFetcher contentFetcher, PageParser pageParser)
	{
		this.contentFetcher = contentFetcher;
		this.pageParser = pageParser;
	}

	@Override
	public IndexPage getIndexPage()
	{
		String content = contentFetcher.getIndexPageContent();
		IndexPage page = pageParser.parseIndexPage(content);

		return page;
	}

	@Override
	public Page getPage(String title)
	{
		String content = contentFetcher.getPageContent(title);
		Page page = pageParser.parsePage(content);

		return page;
	}

}
